#include<iostream>

#include<list>


using namespace std;

//int main()
//{
//	int ar[] = { 0,1, 2, 3, 4,  5, 6, 7, 8, 9 };
//	int n = sizeof(ar) / sizeof(int);
//	list<int> mylist(ar, ar + n);//{ 0,1, 2, 3, 4,  5, 6, 7, 8, 9 }
//	list<int>::iterator pos = find(mylist.begin(), mylist.end(), 5);
//	reverse(mylist.begin(), pos);//432156789
//	reverse(pos, mylist.end());//4321 98765
//	list<int>::const_reverse_iterator crit = mylist.crbegin();
//	while (crit != mylist.crend())
//	{
//		cout << *crit << " ";
//		++crit;
//	}
//
//	cout << endl;
//
//}

int main()

{

	int array[] = { 1, 2, 3, 4, 0, 5, 6, 7, 8, 9 };

	int n = sizeof(array) / sizeof(int);

	list<int> mylist(array, array + n);//{ 1, 2, 3, 4, 0, 5, 6, 7, 8, 9 }

	auto it = mylist.begin();

	while (it != mylist.end())
	{
		if (*it != 0)

			cout << *it << " ";

		else

			it = mylist.erase(it);

		++it;

	}

	return 0;

}
